/*
 * @Author: zhang gen yuan
 * @Date: 2021-09-17 15:48:35
 * @Descripttion: 
 */
export const formColumn = [
    {
        label: '账号',
        prop: 'account'
    },
    {
        label: '密码',
        prop: 'password'
    },
    {
        label: '昵称',
        prop: 'name'
    },
    {
        label: '名称',
        prop: 'realName'
    },
    {
        label: '邮箱',
        prop: 'email'
    },
    {
        label: '手机',
        prop: 'phone'
    },
    // {
    //     label: '生日',
    //     prop: 'birthday'
    // },
    {
        label: '性别',
        prop: 'sex'
    },
    // {
    //     label: '创建人',
    //     prop: 'createUser'
    // },
    // {
    //     label: '创建部门',
    //     prop: 'createDept'
    // },
    // {
    //     label: '创建时间',
    //     prop: 'createTime'
    // },
    // {
    //     label: '修改人',
    //     prop: 'updateUser'
    // },
    // {
    //     label: '修改时间',
    //     prop: 'updateTime'
    // },
    {
        label: '状态',
        prop: 'status'
    }
]

// 手机号校验
const isMobileNumber = (rule, value, callback) => {
    if (!value) {
        callback()
    } else {
        const reg = /^1[3|4|5|7|8][0-9]\d{8}$/;
        const isPhone = reg.test(value);
        value = Number(value); //转换为数字
        if (typeof value === "number" && !isNaN(value)) {
            value = value.toString();
            if (value.length < 0 || value.length > 12 || !isPhone) {
                callback(new Error("请输入有效手机号,号码格式如:138xxxx8754"));
            } else {
                callback();
            }
        } else {
            callback(new Error("请输入电话号码"));
        }
    }
};

export const rules = {
    account: [{ required: true, message: '请输入账号', trigger: 'blur' }],
    password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
    name: [{ required: true, message: '请输入昵称', trigger: 'blur' }],
    realName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
    status: [{ required: true, message: '请输入状态', trigger: 'blur' }],
    phone: [{ message: '请输入有效的手机号', trigger: 'blur' }, { validator: isMobileNumber, trigger: "blur" }],
    email: [{ message: '请输入有效的手机号', trigger: 'blur' }, { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }],
}